﻿namespace Chain.DBUtility
{
    using Chain.Common;
    using Chain.Common.DEncrypt;
    using System;

    public class PubConstant
    {
        public static string ConnectionString
        {
            get
            {
                string text = ConfigHelper.GetValue("ConnString");
                if ((ConfigHelper.GetValue("ConnStringE") == "true") && (text != ""))
                {
                    text = DESEncrypt.Decrypt(text);
                }
                return text;
            }
        }

        public static string DBName
        {
            get
            {
                int startIndex = ConnectionString.IndexOf("database=") + 9;
                int length = ConnectionString.IndexOf(";", startIndex) - startIndex;
                return ConnectionString.Substring(startIndex, length);
            }
        }

        public static string DoMain
        {
            get
            {
                return DESEncrypt.Decrypt(ConfigHelper.GetValue("SystemDomain"));
            }
        }

        public static string Login
        {
            get
            {
                int startIndex = ConnectionString.IndexOf("uid=") + 4;
                int length = ConnectionString.IndexOf(";", startIndex) - startIndex;
                return ConnectionString.Substring(startIndex, length);
            }
        }

        public static string Pwd
        {
            get
            {
                int startIndex = ConnectionString.IndexOf("pwd=") + 4;
                int length = ConnectionString.IndexOf(";", startIndex) - startIndex;
                return ConnectionString.Substring(startIndex, length);
            }
        }

        public static string ServerIP
        {
            get
            {
                int startIndex = ConnectionString.IndexOf("server=") + 7;
                int length = ConnectionString.IndexOf(";", startIndex) - startIndex;
                return ConnectionString.Substring(startIndex, length);
            }
        }
    }
}

